<?php
App::import('Vendor','desmondpdf');

// create new PDF document
$pdf = new DESMONDPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Desmond');
$pdf->SetTitle('Liquidación de expensas');
$pdf->SetSubject('Notificación de liquidación de expensas');
$pdf->SetKeywords('TCPDF, PDF, liquidacion, expensas');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
//$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// set font
$pdf->SetFont('times', 'BI', 12);

// add a page
$pdf->AddPage();

// NON-BREAKING TABLE (nobr="true")

$tbl = <<<EOD
<h1>Liquidación de expensas</h1>

<p><i>Sr./Sra. $nameOccupant </i></p>


<table cellpadding="2" cellspacing="2" nobr="true" width="100%">
 <tr>   
  <th colspan="2" align="left">Resumen</th>
 </tr>
 <tr>
  <td colspan="2"><hr/></td>
 </tr>
 <tr>
  <td>Deuda Previa (hasta ahora)  $dateExpense</td>
  <td align="right">$$debtAmount</td>
 </tr>
 <tr>
  <td>Intereses</td>
  <td align="right">$$interests</td>
 </tr>
 <tr>
  <td>Expensas mes  $dateExpense</td> 
  <td align="right">$$expenseAmount</td>
 </tr> 
 <tr>
  <td colspan="2"><hr/></td>
 </tr>
 <tr>
  <td>Total del mes Expensas  $typeExpense</td>
  <td align="right">$$total</td>
 </tr>
</table>
EOD;

$pdf->writeHTML($tbl, true, false, false, false, '');

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output($filetmp, 'F');
?>
